<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">



<h:head>
</h:head>
<h:body>

	<ui:composition template="masterpage.xhtml">

		<ui:define name="cont">

			<h:form id="formListarContas" acceptcharset="ISO-8859-1">
				<div class="table-responsive">

					<p:dataTable id="tableContas" var="conta"
						value="#{listarContasBean.contas}"
						tableStyleClass="table no-border hover"
						rowStyleClass="no-border-y" paginator="true" rows="10"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15" >

						<p:column headerText="Título" style="width:30%"
							styleClass="no-border">
							<h:outputText value="#{conta.titulo}" />
						</p:column>

						<p:column headerText="Saldo" styleClass="text-right no-border">
							<h:outputText
								style="color: #{conta.saldo lt 0 ? 'red' : 'none'};"
								value="#{conta.saldo}"
								styleClass="text-right color-success text-right">
								<f:convertNumber type="currency" currencySymbol="R$" />
							</h:outputText>
						</p:column>

						<p:column headerText="Ação" style="width:15%;"
							styleClass="text-center no-border text-center">
							<h:outputText value="#{car.manufacturer}" />

							<p:commandLink id="cmdLinkAlterar"
								styleClass="label label-default" oncomplete="funcMask()" onclick="dlg.show()" update=":formModalAlterarConta">
								<f:setPropertyActionListener
									target="#{modalAlterarContaBean.contaSelecionada}"
									value="#{conta}" />
								<i class="fa fa-pencil"></i> 
							</p:commandLink>
							

							<p:commandLink id="cmdLinkExcluir"
								styleClass="label label-danger" onclick="confirm.show()">
								<f:setPropertyActionListener
									target="#{listarContasBean.contaSelecionada}" value="#{conta}" />
								<i class="fa fa-times"></i>
							</p:commandLink>
						</p:column>
					</p:dataTable>
				</div>

			</h:form>

			<p:confirmDialog id="dialogExcluir" global="true" widgetVar="confirm"
				message="Deseja excluir o registro ?" header="Confirmação">
				<p:commandButton value="Sim"
					action="#{listarContasBean.removerConta}"
					styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
					oncomplete="confirm.hide();" update=":formListarContas:tableContas" />

				<p:commandButton value="Não" type="button"
					styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
			</p:confirmDialog>

				<p:dialog id="mdlAlterarConta" header="Alterar Conta"
					widgetVar="dlg" height="250" width="500"
					resizable="false" modal="true" >

					<h:form id="formModalAlterarConta" class="form-horizontal"
						action="#" style="border-radius: 0px;" acceptcharset="ISO-8859-1">
						
						<div class="form-group">
							<h:outputLabel id="outSaldo" value="Saldo R$"
								styleClass="col-sm-3 control-label" />
							<div class="col-sm-6">
								<h:inputText id="inptSaldo" styleClass="form-control money"
									value="#{modalAlterarContaBean.contaSelecionada.saldo}">
									<f:convertNumber pattern="#,###,##0.00" />
								</h:inputText>

								<div class="checkbox">
									<label> <h:selectBooleanCheckbox id="chkNegativo"
											value="#{modalAlterarContaBean.negativo}" /> Negativo
									</label>
								</div>
							</div>
						</div>
						
						<div class="form-group">
							<h:outputLabel id="outTitulo" value="Título"
								styleClass="col-sm-3 control-label" />
							<div class="col-sm-6">
								<h:inputText id="inptTitulo" styleClass="form-control"
									value="#{modalAlterarContaBean.contaSelecionada.titulo}" required="true" />
								<h:message id="msg" for="inptTitulo" class="mensagens" />
							</div>
						</div>

						<div class="form-group" style="margin-left:45px;">
							<div class="col-sm-offset-2 col-sm-10">
								
								<p:commandButton id="btnSalvar"
									action="#{modalAlterarContaBean.alteraConta}"
									value="Salvar" 
									update=":formListarContas:tableContas msg"
									oncomplete="handleLoginRequest(xhr, status, args)" />

								<p:commandButton  id="btnVoltar"
									value="Voltar"  oncomplete="dlg.hide()" process="@this"/>
							</div>
						</div>

					</h:form>
				</p:dialog>
	

		</ui:define>
		<ui:param name="titulo" value="Conta" />
		<ui:param name="tituloPagina" value="Listar Contas" />
	</ui:composition>



</h:body>
</html>